<?php
class Facility extends FacilityPeer
{
	function Facility()
	{
		parent::FacilityPeer();
	}
	
	
	public static function getAllFacilities($for='HOTEL')
	{
		$db = new Database();
		if ($for != 'BOTH')
			$query = "SELECT id FROM facility WHERE facility_for = '".$for."'";
		else
			$query = "SELECT id FROM facility";
		$db->query($query);
		$ids = $db->fetch_array($db->result);
		$facilities = array();
		if ($ids)
			foreach ($ids as $id) {
				$facility = new Facility();
				$facility->select($id['id']);
				if (!array_key_exists($facility->getcategory(), $facilities))
					$facilities[$facility->getcategory()] = array();
					
				$facilities[$facility->getcategory()][] = $facility;
			}
		
		return $facilities;
	}
}
?>